]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Move restacking handling from WorkspacesView to WorkspacesDisplay
authorOwen W. Taylor <otaylor@fishsoup.net>
Mon, 31 Jan 2011 01:44:05 +0000 (20:44 -0500)
committerOwen W. Taylor <otaylor@fishsoup.net>
Wed, 9 Feb 2011 00:43:20 +0000 (19:43 -0500)
Moving the base tracking of restacking to WorkspacesDisplay will allow
us to use it to update stacking in the workspace thumbnails as well as
in the main workspaces.

https://bugzilla.gnome.org/show_bug.cgi?id=640996

js/ui/workspacesView.js

index 9c3c8cd0eb3a12306f54533de70a97249f6e4668..8f97d0ee988765d675fc6705e1278e2db093bcd1 100644 (file)
@@ -77,7 +77,6 @@ WorkspacesView.prototype = {
         this._overviewShowingId =
             Main.overview.connect('showing',
                                  Lang.bind(this, function() {
-                this._onRestacked();
                 for (let w = 0; w < this._workspaces.length; w++)
                     this._workspaces[w].zoomToOverview();
         }));
@@ -99,9 +98,6 @@ WorkspacesView.prototype = {
         this._switchWorkspaceNotifyId =
             global.window_manager.connect('switch-workspace',
                                           Lang.bind(this, this._activeWorkspaceChanged));
-        this._restackedNotifyId =
-            global.screen.connect('restacked',
-                                  Lang.bind(this, this._onRestacked));
 
         this._itemDragBeginId = Main.overview.connect('item-drag-begin',
                                                       Lang.bind(this, this._dragBegin));
@@ -207,15 +203,7 @@ WorkspacesView.prototype = {
         return this._workspaces[0].scale;
     },
 
-    _onRestacked: function() {
-        let stack = global.get_window_actors();
-        let stackIndices = {};
-
-        for (let i = 0; i < stack.length; i++) {
-            // Use the stable sequence for an integer to use as a hash key
-            stackIndices[stack[i].get_meta_window().get_stable_sequence()] = i;
-        }
-
+    syncStacking: function(stackIndices) {
         for (let i = 0; i < this._workspaces.length; i++)
             this._workspaces[i].syncStacking(stackIndices);
     },
@@ -502,7 +490,6 @@ WorkspacesView.prototype = {
         this._scrollAdjustment.run_dispose();
         Main.overview.disconnect(this._overviewShowingId);
         global.window_manager.disconnect(this._switchWorkspaceNotifyId);
-        global.screen.disconnect(this._restackedNotifyId);
 
         if (this._timeoutId) {
             Mainloop.source_remove(this._timeoutId);
@@ -824,6 +811,10 @@ WorkspacesDisplay.prototype = {
             global.screen.connect('notify::n-workspaces',
                                   Lang.bind(this, this._workspacesChanged));
 
+        this._restackedNotifyId =
+            global.screen.connect('restacked',
+                                  Lang.bind(this, this._onRestacked));
+
         if (this._itemDragBeginId == 0)
             this._itemDragBeginId = Main.overview.connect('item-drag-begin',
                                                           Lang.bind(this, this._dragBegin));
@@ -836,6 +827,8 @@ WorkspacesDisplay.prototype = {
         if (this._windowDragEndId == 0)
             this._windowDragEndId = Main.overview.connect('window-drag-end',
                                                           Lang.bind(this, this._dragEnd));
+
+        this._onRestacked();
     },
 
     hide: function() {
@@ -845,6 +838,10 @@ WorkspacesDisplay.prototype = {
             global.screen.disconnect(this._nWorkspacesNotifyId);
             this._nWorkspacesNotifyId = 0;
         }
+        if (this._restackedNotifyId > 0){
+            global.screen.disconnect(this._restackedNotifyId);
+            this._restackedNotifyId = 0;
+        }
         if (this._itemDragBeginId > 0) {
             Main.overview.disconnect(this._itemDragBeginId);
             this._itemDragBeginId = 0;
@@ -870,6 +867,18 @@ WorkspacesDisplay.prototype = {
         }
     },
 
+    _onRestacked: function() {
+        let stack = global.get_window_actors();
+        let stackIndices = {};
+
+        for (let i = 0; i < stack.length; i++) {
+            // Use the stable sequence for an integer to use as a hash key
+            stackIndices[stack[i].get_meta_window().get_stable_sequence()] = i;
+        }
+
+        this.workspacesView.syncStacking(stackIndices);
+    },
+
     _workspacesChanged: function() {
         let oldNumWorkspaces = this._workspaces.length;
         let newNumWorkspaces = global.screen.n_workspaces;